package us.versus.them.kitkattoe;

import flash.display.Graphics;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.geom.Point;
import flash.media.Sound;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;

import flash.display.Bitmap;
import flash.display.BitmapData;

class Versus extends Base {
	var app:App;
	var timer:Timer;
	var me:BitmapData;
	var yu:BitmapData;

	public function new( app, me, yu ) {
		super();
		this.app = app;
		this.me = me;
		this.yu = yu;

		add( Base.displayObjectForName( 'versus' ) );

		var meB = new Bitmap( me );
		var yuB = new Bitmap( yu );

		yuB.x = 40;
		meB.x = yuB.x + 220;

		meB.y = yuB.y = 140;
		add( yuB );
		add( meB );

		this.timer = new Timer( 1000 * 3, 1 );
		this.timer.addEventListener( TimerEvent.TIMER , nu );
		this.timer.start();
		this.addEventListener( MouseEvent.MOUSE_DOWN, mouse_down );
	}

	public function add( x:DisplayObject ) {
		addChild( x );
	}

	public override function mouse_down( mouseEvent : MouseEvent ) {
		this.nu();
	}

	public function nu( ?d:Dynamic ) {
		this.timer.stop();
		this.app.versus_done( this.me, this.yu );
		removeEventListeners();
	}
}
